package com.beiding.pojo;

import com.google.common.collect.Lists;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

public class Group {

    private List<StaticResource> resources = Lists.newArrayList();

    public static Group create(MultipartFile[] multipartFiles){
        Group resourceGroup =  new Group();
        for (MultipartFile multipartFile:multipartFiles)
        {
            if (multipartFile.getSize()>0)
                resourceGroup.resources.add(new MultipartFileResource(multipartFile));
        }
        return resourceGroup;
    }
    private Group() {
    }

    public List<String> getMemberIds() {

        List<String> r = Lists.newArrayList();
        resources.forEach(
                it -> r.add(it.getId())
        );
        return r;
    }


    public List<StaticResource> getMembers() {
        return resources;
    }

    public void persistent(){
        resources.forEach(
                StaticResource::persistent
        );
    }


}
